package com.xoa.controller.party;


import com.xoa.model.party.Illegalrentgroup;
import com.xoa.service.party.IllegalRentService;
import com.xoa.util.ToJson;
import com.xoa.util.common.wrapper.BaseWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.beans.Transient;

/**
 * Created by 程叶同 on 2018/1/10.
 */
@Controller
@RequestMapping("illeralrent")
public class IllegalRentController {
    @Autowired
    IllegalRentService illegalRentService;

    @RequestMapping("addRent")
    @ResponseBody
    public BaseWrapper addRent(Illegalrentgroup illegalrentgroup){
        return  illegalRentService.addRent(illegalrentgroup);
    }

    @RequestMapping("deleteRent")
    @ResponseBody
    public BaseWrapper deleteRent(Integer id){
        return  illegalRentService.deleteRent(id);
    }

    @RequestMapping("updateRent")
    @ResponseBody
    public BaseWrapper updateRent(Illegalrentgroup illegalrentgroup){
        return  illegalRentService.updateRent(illegalrentgroup);
    }
    @RequestMapping("getRentById")
    @ResponseBody
    public BaseWrapper getRentById(Integer id){
        return  illegalRentService.getRentById(id);
    }
    @RequestMapping("getList")
    @ResponseBody
    public BaseWrapper getList(Integer page, Integer pageSize, String subStreet, String subArea, String buildingDoor, String mainrentName,
                               @RequestParam(value = "useFlag",required=false) boolean useFlag){
        return  illegalRentService.getList(page,pageSize,subStreet,subArea,buildingDoor,mainrentName,useFlag);
    }

    @RequestMapping("outPutFile")
    @ResponseBody
    public BaseWrapper outPutFile(HttpServletRequest request, HttpServletResponse response, String ids){
        return  illegalRentService.outPutFile(request,response,ids);
    }

    @RequestMapping("/ecoudInsert")
    @ResponseBody
    @Transient
    public ToJson ecoudInsert(MultipartFile file, HttpServletRequest reques){
        return illegalRentService.ecoudInsert(file,reques);
    }

    /**
     *郭心雨
     * 查询全部出租屋新
     * @return
     */
    @RequestMapping("getListNew")
    @ResponseBody
    public BaseWrapper getListNew(Integer page, Integer pageSize, String subStreet, String subArea, String buildingDoor, String mainrentName,
                                  @RequestParam(value = "useFlag",required=false) boolean useFlag){
        return  illegalRentService.getListNew(page,pageSize,subStreet,subArea,buildingDoor,mainrentName,useFlag);
    }

    /**
     * 获取某栋楼中出租屋的信息
     * @param gridLocation
     * @return
     */
    @RequestMapping("getRentByLoc")
    @ResponseBody
    public BaseWrapper getRentByLoc(Integer page, Integer pageSize, String gridLocation){
        return  illegalRentService.getRentByLoc( page, pageSize,gridLocation);
    }
}
